const wearDao=require('../dao/weraDao');


async function findByKind(kind) {
    if(kind==null||kind=={}||kind==undefined||kind==[]){
        kind='kid';
    }
    try{
        //查询衣服，能返回
        var data=await wearDao.findByKind(kind);
        return {success:true,child:data};
    }catch (e) {
        //不能返回
        return {success:false,msg:'database is error!'};
    }
}

async function findByWomenKind(kind) {
    if(kind==null||kind=={}||kind==undefined||kind==[]){
        kind='women';
    }
    try{
        //查询衣服，能返回
        var data=await wearDao.findByKind(kind);
        return {success:true,women:data};
    }catch (e) {
        //不能返回
        return {success:false,msg:'database is error!'};
    }
}

async function findByMenKind(kind) {
    if(kind==null||kind=={}||kind==undefined||kind==[]){
        kind='men';
    }
    try{
        //查询衣服，能返回
        var data=await wearDao.findByKind(kind);
        return {success:true,men:data};
    }catch (e) {
        //不能返回
        return {success:false,msg:'database is error!'};
    }
}

async function findByMobileKind(kind) {
    if(kind==null||kind=={}||kind==undefined||kind==[]){
        kind='mobile';
    }
    try{
        //查询衣服，能返回
        var data=await wearDao.findByKind(kind);
        return {success:true,mobile:data};
    }catch (e) {
        //不能返回
        return {success:false,msg:'database is error!'};
    }
}

exports.findByKind=findByKind;
exports.findByWomenKind=findByWomenKind;
exports.findByMenKind=findByMenKind;
exports.findByMobileKind=findByMobileKind;